package com.yami.shop.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yami.shop.bean.dto.MeltCloudGroupsAndUserDTO;
import com.yami.shop.bean.dto.MeltCloudGroupsDTO;
import com.yami.shop.bean.model.MeltCloudGroup;
import com.yami.shop.bean.vo.MeltCloudGroupsVo;
import com.yami.shop.common.response.ServerResponseEntity;
import com.yami.shop.common.util.PageParam;
import com.yami.shop.service.MeltCloudGroupUserService;
import com.yami.shop.service.MeltCloudUserService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/melt")
public class MeltCloudSysController {


    @Autowired
    private MeltCloudUserService meltCloudUserService;

    @Autowired
    private MeltCloudGroupUserService groupUserService;

    @PostMapping("/conversationList")
    @Operation(summary =  "会话详细信息", description = "会话详细信息")
    public ServerResponseEntity<MeltCloudGroupsVo> conversationList(@RequestBody List<MeltCloudGroupsDTO> groups) {
        return ServerResponseEntity.success(meltCloudUserService.getDetail(groups));
    }

    @PostMapping("/conversationListAll")
    @Operation(summary =  "会话详细信息组装完", description = "会话详细信息")
    public ServerResponseEntity<List<MeltCloudGroupsDTO>> conversationListAll(@RequestBody MeltCloudGroupsAndUserDTO groups) {
        return ServerResponseEntity.success(meltCloudUserService.getConversationDetail(groups));
    }


    @GetMapping("/groups")
    @Operation(summary =  "加入的群组列表", description = "加入的群组列表")
    public ServerResponseEntity<List<MeltCloudGroup>> groups(@RequestParam("userId") String userId,String userName) {
        return ServerResponseEntity.success(meltCloudUserService.groups(userId,userName));
    }

    @GetMapping("/groupsPage")
    @Operation(summary =  "加入的群组列表分页", description = "加入的群组列表分页")
    public ServerResponseEntity<IPage<MeltCloudGroup>> groupsPage(PageParam<MeltCloudGroup> page, @RequestParam("userId") String userId, String userName, Boolean ignoreProhibition) {
        return ServerResponseEntity.success(meltCloudUserService.groupsPage(page,userId,userName,ignoreProhibition));
    }
    @GetMapping("/groupsCount")
    @Operation(summary =  "加入的群组数量", description = "加入的群组列表数量")
    public ServerResponseEntity<Long> groupsCount(@RequestParam("userId") String userId, String userName) {
        return ServerResponseEntity.success(meltCloudUserService.groupsCount(userId,userName));
    }
}
